import config from "@/config"
import http from "@/utils/request"
import qs from "qs"

export default {
	successCode: config.API_SUCCESS_CODE,
	api: {
		add: {
			url: `${config.API_URL}/sys/user/add`,
			post: async function(data){
				data = qs.stringify(data)
				return await http.post(this.url,data);
			}
		},
		edit: {
			url: `${config.API_URL}/sys/user/edit`,
			post: async function(data){
				data = qs.stringify(data)
				return await http.post(this.url,data);
			}
		},
		del: {
			url: `${config.API_URL}/sys/user/del`,
			post: async function(data){
				data = qs.stringify(data, { indices: false })
				return await http.post(this.url,data);
			}
		},
		list: {
			url: `${config.API_URL}/sys/user/list`,
			get: async function(data){
				return await http.get(this.url,data);
			}
		},
		approval: {
			url: `${config.API_URL}/sys/user/approve`,
			post: async function(data){
				data = qs.stringify(data)
				return await http.post(this.url,data);
			}
		},
		disable: {
			url: `${config.API_URL}/sys/user/disable`,
			post: async function(data){
				data = qs.stringify(data)
				return await http.post(this.url,data);
			}
		},
		passwordReset: {
			url: `${config.API_URL}/sys/user/password`,
			post: async function(data){
				data = qs.stringify(data)
				return await http.post(this.url,data);
			}
		},
		passwordModify: {
			url: `${config.API_URL}/my/password`,
			post: async function(data){
				data = qs.stringify(data)
				return await http.post(this.url,data);
			}
		},
		profile: {
			url: `${config.API_URL}/my/profile`,
			get: async function(){
				return await http.get(this.url);
			},
			post: async function(data){
				data = qs.stringify(data)
				return await http.post(this.url,data);
			}
		},
		rolesList: {
			url: `${config.API_URL}/sys/user/roles/list`,
			get: async function(data){
				return await http.get(this.url,data);
			}
		},
		rolesSave: {
			url: `${config.API_URL}/sys/user/roles/save`,
			post: async function(data){
				data = qs.stringify(data, { indices: false })
				return await http.post(this.url,data);
			}
		}
	}
}
